<?php
//日本語
class SearchController extends AppController {

	var $name = 'Search';
	var $uses = array('User', 'Post', 'Profile');
	var $components = array('Pmaimai', 'RequestHandler');
	var $helpers = array('Html', 'Form');
	
	function index()
	{
		$this->set('error', false);
		$this->set('results', false);
		$this->Pmaimai->checkMemberAuth();
		$userID = $this->Session->read($this->sessionUserName);
		
		$this->User->recursive = 0;
		$user = $this->User->findById($userID);
		if(!$user){
			$this->redirect('/');
		}
		$this->set('user', $user);
		
		if(!isset($this->params['url']['word'])){
			return;
		}
		
		$cond = array();
		$cond['status'] = 'active';
		if(!empty($this->params['url']['word'])){
			$cond['nickname'] = "LIKE %".$this->params['url']['word']."%";
		}
		
		$this->User->recursive = -1;
		$results = $this->User->findAll($cond);
		$this->set('results', $results);

	}
	
	function advanced()
	{
		$this->set('error', false);
		$this->Pmaimai->checkMemberAuth();
		$userID = $this->Session->read($this->sessionUserName);
		
		$this->User->recursive = 0;
		$user = $this->User->findById($userID);
		if(!$user){
			$this->redirect('/');
		}
		$this->set('user', $user);
		
		if(!isset($this->data['Search'])){
			return;
		}

	}


}
?>